<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class C_Login extends CI_Controller {

    //加载Controller
    public function __construct() {
        parent::__construct();
        $this->load->model('Users_Model');
        $this->load->model('System_Model');
    }

    //初始化登陆页面
    public function index() {
         $data['title'] = $this->System_Model->get_system('login_title');
        if (empty($data['title'])) {
             redirect('system/C_System/syste_init');
        }
        $userName = $this->input->post('user_name');
        $password = $this->input->post('user_password');
        if ($userName && $password) {
            $rows = $this->Users_Model->login_users($userName, $password);
            if ($rows > 0) {
                redirect('C_Main/index');
            } else {
                $this->session->set_userdata('alertContent', "亲，请注意用户名 、密码不要写错哦！");
            }
        }
        $this->load->view('login_view',$data);
    }

    //查看sesion中是否存在需要提示的内容。
    function ajax_alert() {
        $data = $this->session->userdata('alertContent');
        echo $data;
    }

    //清楚session中的内容
    function ajax_clear() {
        $this->session->unset_userdata('alertContent');
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */